function lambda = adjustment(adjtype, L, alpha, alphapos, menucost, lbar,omega,Pgrid, pStar)
% Returns matrix of adjustment probabilities as a function of the state
%Pgrid, pStar log price grid and log optimal price

switch adjtype
    case 1                    % SSDP 
        aL = (menucost./L).^(1/alpha);  % JME paper has ksi-->(1/ksi)                              
        lambda = lbar./((1-lbar)*aL+lbar);             
    case 2                    % CALVO
        lambda = lbar*ones(size(L)) ;
    case {3}              % MC, PPS, ENT: INDICATOR FUNCTION L>=adjcost
         lambda = lamcontin_ind(L);
         % lambda = L > 0; 
    case {4}                % WOODFORD-LOG and WOODFORD-ENT
        argexp = -L/alpha;    %argexp = (menucost-L)/alpha;      
        lambda = lbar./((1-lbar).*exp(argexp) + lbar); 
%     case {8,9}                % NESTED LOGIT and NESTED ENTROPY with interp
%         argexp = -L/alpha;
%         lambdaW = lbar./((1-lbar).*exp(argexp) + lbar); 
%         lambda = lambdaW;    
%         % INTERPOLATION (needed for dynamics only)
%         % nr = size(argexp,1);
%         % argexpinterp = ...
%         %      interp1((1:nr)',argexp,(0.5:0.1:nr+0.5)','linear','extrap');
%         %         
%         % lambdaSmoothBIG = lbar./((1-lbar).*exp(argexpinterp) + lbar); 
%         % for i = 0:nr-1
%         %   lambdaSmooth(i+1,:) = mean(lambdaSmoothBIG(i*10+1:i*10+11,:));
%         % end
%         % weightS = 1./(1+argexp.^2);          % ENSURE THIS IS POSITIVE
%         % lambda = (1-weightS).*lambdaW + weightS.*lambdaSmooth;
    case 5
      %lambda = min(lbar+alpha*abs(Pgrid-ones(length(Pgrid),1)*pStar),ones(length(Pgrid),1));
      lambda = min(omega+alpha*abs(Pgrid-ones(length(Pgrid),1)*pStar),ones(length(Pgrid),1));
      %lambda = min(lbar+alpha*abs(L),ones(length(Pgrid),1));
    case 6
      %lambda = min(lbar+alpha*abs(Pgrid-ones(length(Pgrid),1)*pStar),ones(length(Pgrid),1));
      gap_pos_indicator = (Pgrid-ones(length(Pgrid),1)*pStar)>=zeros(length(Pgrid),1);
      lambda = min(omega-alpha*(1-gap_pos_indicator).*(Pgrid-ones(length(Pgrid),1)*pStar)+...
                            alphapos*(gap_pos_indicator).*(Pgrid-ones(length(Pgrid),1)*pStar),ones(length(Pgrid),1));
      %lambda = min(lbar+alpha*abs(L),ones(length(Pgrid),1));
    case 7
      lambda = min(omega+alpha*abs(L),ones(length(Pgrid),1));  %omega+(1-omega)*1/mcbar*abs(L)
end  
end

